/****************************************************************************
 *
 *  3DSFILE.H
 *
 *  (C) Copyright 1997 by Autodesk, Inc.
 *
 *  This program is copyrighted by Autodesk, Inc. and is licensed to you under
 *  the following conditions.  You may not distribute or publish the source
 *  code of this program in any form.  You may incorporate this code in object
 *  form in derivative works provided such derivative works are (i.) are de-
 *  signed and intended to work solely with Autodesk, Inc. products, and (ii.)
 *  contain Autodesk's copyright notice "(C) Copyright 1995 by Autodesk, Inc."
 *
 *  AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  AUTODESK SPE-
 *  CIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
 *  A PARTICULAR USE.  AUTODESK, INC.  DOES NOT WARRANT THAT THE OPERATION OF
 *  THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.
 *
 ***************************************************************************/

#ifndef FILE_3DS_H
#define FILE_3DS_H

#include "3DSTYPE.H"
#include "3DSRANGE.H"
#include "3DSERR.H"

/* Private Typedefs */

/* filestate3ds - Read/write state of a file */
typedef enum 
{
   StateNotKnown = 0, /* No state determined yet, file not open */
   ReadFromFile = 1,  /* Open for read */
   WriteToFile = 2,   /* Open for write */
   ReadWriteFile = 3  /* Open for read and write, not used by toolkit */
} filestate3ds;
/* End Private */

/* Public Typedefs */

/* file3ds - Handle to 3D Studio files */
typedef struct
{
   FILE *file;         /* stdio file pointer */
   char3ds *filename;  /* name of file */
   filestate3ds state; /* file open state */
   ubyte3ds index;     /* Position of pointer in the FileContextList, if the
                          index eq InvalidFileContext3ds, then it is not in the
                          list */
   void *buffer;       /* Buffered I/O buffer */
   ulong3ds buffersize;
   byte3ds istempfile; /* True3ds if file is a temp file */
} file3ds;
/* End Public */

static const ubyte3ds InvalidFileContext3ds = 255; /* Signifies an invalid file pointer, or
						      a file pointer without a position */

#ifdef __cplusplus
extern "C" {
#endif


void InitContextList3ds();
void ReleaseContextList3ds();
void AddContext3ds(file3ds *file);
void DelContext3ds(file3ds *file);
void SetContextByIndex3ds(ubyte3ds index);
byte3ds IsValidFileIndex3ds(ubyte3ds index);
file3ds *GetContextByIndex3ds(ubyte3ds index);
ubyte3ds GetContextIndex3ds();
void SetContext3ds(file3ds *file);
file3ds *GetContext3ds();
void SetFileName3ds(const char3ds *filename);
char3ds *GetFileName3ds();
void SetFile3ds(FILE *file);
FILE *GetFile3ds();
void InitFile3ds(file3ds **file);
ulong3ds GetFilePosition3ds();
short3ds FileSeek3ds(long3ds newposition);
void RenameFileToTemp3ds(file3ds *file);


/* Public Prototypes */

/* File control functions */
file3ds *OpenFile3ds(const char3ds *filename, const char *attrib);
void CloseAllFiles3ds();
void CloseFile3ds(file3ds *file);

#ifdef __cplusplus
}
#endif


/* End Public */
#endif
